package cn.wcy.design_patterns.creationtype01.abstractfactory02;

import cn.wcy.design_patterns.creationtype01.abstractfactory02.impl.CacheServiceImpl;
import cn.wcy.design_patterns.creationtype01.abstractfactory02.impl.EGMCacheServiceImpl;
import cn.wcy.design_patterns.creationtype01.abstractfactory02.impl.IIRCacheServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/test")
public class ApiTestController {

    @GetMapping("/cache/egm")
    public String cache() {
        CacheService proxy_EGM = Factory.getInvokeStrategy(EGMCacheServiceImpl.class.getSimpleName());
        proxy_EGM.set("user_name_01", "小傅哥");
        return proxy_EGM.get("user_name_01");
    }

    @GetMapping("/cache/iir")
    public String cacheIir() {
        CacheService proxy_IIR = Factory.getInvokeStrategy(IIRCacheServiceImpl.class.getSimpleName());
        proxy_IIR.set("user_name_02", "小杨哥");
        return proxy_IIR.get("user_name_02");
    }

    @GetMapping("/cache/redis")
    public String cacheRedis() {
        CacheService proxy_Cache = Factory.getInvokeStrategy(CacheServiceImpl.class.getSimpleName());
        proxy_Cache.set("user_name_03", "奥特曼");
        return proxy_Cache.get("user_name_03");
    }
}
